package me.zhengjie.modules.workorder.service;

import me.zhengjie.modules.workorder.domain.TWorkOrder;
import me.zhengjie.modules.workorder.service.dto.TWorkOrderDTO;
import me.zhengjie.modules.workorder.service.dto.TWorkOrderQueryCriteria;
import me.zhengjie.modules.workorder.service.dto.TWorkOrderQueryCriteriaEx;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.ArrayList;
import java.util.List;

/**
* @author zcw
* @date 2019-08-13
*/
//@CacheConfig(cacheNames = "tWorkOrder")
public interface TWorkOrderService {

    /**
    * queryAll 分页
    * @param criteria
    * @param pageable
    * @return
    */
    //@Cacheable(keyGenerator = "keyGenerator")
    Object queryAll(TWorkOrderQueryCriteria criteria, Pageable pageable);
    Object queryAll(TWorkOrderQueryCriteriaEx criteria, Pageable pageable);

    /**
     * 获取可以接单的订单,根据供应商(派单)后的记录进行查询
     * @param major
     * @param level
     * @param country
     * @param province
     * @param city
     * @param county
     * @param supplier
     * @return
     */
    Object queryAcceptableWorkOrder(String major,
                             ArrayList<String> level,
                             String country,
                             String province,
                             String city,
                             String county,
                             Long supplier,
                             Pageable pageable);

    Long countAcceptableWorkOrder(String major,
                                     ArrayList<String> level,
                                     String country,
                                     String province,
                                     String city,
                                     String county,
                                     Long supplier);
    /**
    * queryAll 不分页
    * @param criteria
    * @return
    */
    //@Cacheable(keyGenerator = "keyGenerator")
    public Object queryAll(TWorkOrderQueryCriteria criteria);

    /**
     * findById
     * @param id
     * @return
     */
    //@Cacheable(key = "#p0")
    TWorkOrderDTO findById(Long id);

    /**
     * create
     * @param resources
     * @return
     */
    //@CacheEvict(allEntries = true)
    TWorkOrderDTO create(TWorkOrder resources);
    void create(List<TWorkOrder> resources);

    /**
     * update
     * @param resources
     */
    //@CacheEvict(allEntries = true)
    void updateBeforeAssign(TWorkOrder resources);

    /**
     * delete
     * @param id
     */
    //@CacheEvict(allEntries = true)
    void delete(Long id);
    
    void assign(TWorkOrder resources);
    void batchAssign(TWorkOrder resources);
    
    void acceptEx(TWorkOrder resources);
    
    void refuse(TWorkOrder resources);
    
    void repair(Long id);
    
    void reform(TWorkOrder resources);
    
    void check(Long id);
    
    void back(Long id);

    public List<?> getWorkOrderAggByStatus(Long serviceproviderid, Long supplier);


    //根据编号查找工单
    public TWorkOrder findByOrderCode(String orderCode);


    /**
     * 服务商/客户服务报表统计
     * @param criteria
     * @param pageable
     * @return
     */
    Page<java.util.Map<?,?>> queryWorkorderReport(TWorkOrderQueryCriteriaEx criteria, Pageable pageable);
    List<java.util.Map<?,?>> queryWorkorderReport(TWorkOrderQueryCriteriaEx criteria);
}